<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>费用支出查询</title>
		<%include("/common/include.html"){}%>
		<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
		<style type="text/css">
			.textbox{
				padding-right:0px;
				background:url("${cxt !}/sb/themes/insdep/images/combo_arrow.png") no-repeat scroll right center transparent;
			} 
		</style>
	</head>
	<body class="easyui-layout">
			<div data-options="region:'north',split: true,title:'快速查询'" style="height:200px;padding:10px;">
				<form id="scostSearchFrom" >
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">支出时间-开始时间</label>
						<input id="startTime" name="_query.startTime" value='${startTime !}' class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center" 
							data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">支出时间-结束时间</label>
						<input id="endTime" name="_query.endTime" value='${date(),dateFormat="yyyy-MM-dd"}' class="easyui-datebox theme-textbox-radius" style="height:32px;width:212px;text-align:center" 
							data-options="editable: false,icons:[{
		                        iconCls:'icon-clear',
		                        handler: function(e){
		                            $(e.data.target).datetimespinner('clear');
		                        }
		                    }]"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">代理商/门店</label>
						<input id="organ" type="text" readonly style="width: 200px; height: 30px; padding-left: 10px;border-radius:3px" onclick="showMenu(); return false;" class="textbox" value="${organization.name! }"/>
						<input name="_query.organIds" id="organIds" type="hidden" value="${organization.ids! }">
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">支出类别</label>
<!-- 						<#code type="select" name="_query.jdfs" code="code_jdfs" isSelectDef="false" class="easyui-combobox inputBox theme-textbox-radius" style="width:212px;height:32px;text-align:center;" dataOptions="editable:false"/> -->
						<#code type="select" id="fyzc_select" name="_query.zcType" code="code_fyzc" isSelectDef="false"  class="easyui-combobox inputBox theme-textbox-radius" style="height:32px;width:212px;text-align:center" />
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">支付方式</label>
						<#code type="select" id="skfs_select" name="_query.zffs" code="code_skfs" isSelectDef="false"  class="easyui-combobox inputBox theme-textbox-radius" style="height:32px;width:212px;text-align:center" />
					</div>
					<div style="margin-bottom: 10px;float:left;margin-right: 10px;">
						<label class="label-top" style="width: 100%; display: block;">支出人员</label>
						<#organization type="select" id="zcry_select" name="_query.zcUser"   class="easyui-combobox inputBox theme-textbox-radius" organization="${organization.ids! }" style="height:32px;width:212px;text-align:center"/>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-top: 16px;margin-right: 10px;">
						<a href="#" onclick='searchFrom()' class="easyui-linkbutton" data-options="iconCls:'icon-search'" style="width:212px">搜索</a>
					</div>
					<div style="margin-bottom: 10px;float:left;margin-top: 16px;margin-right: 10px;">
						<a href="#" onclick='customerInfo_xls()' class="easyui-linkbutton" data-options="iconCls:'icon-pageexcel'" style="width:212px">导出</a>
					</div>
					</form>
	   	 	</div>
			<div data-options="region:'center',border: false" style="overflow-x:hidden;">
				<table id="scost_datagrid" class="easyui-datagrid"  style="width: 100%; height: 100%;">
				
				</table>					
			</div>
			<div id="menuContent" class="menuContent" style="display: none; position: absolute;z-index: 10;">
				<ul id="organSelectTree" class="ztree" style="margin-top:0;width: 200px;"></ul>
			</div>
			<script src="sb/js/statistic/scost/scost.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			function customerInfo_xls(){
				var startTime = $("#startTime").val();
				var endTime = $("#endTime").val();
				var organIds = $("#organIds").val();
				var fyzc_select = $("#fyzc_select").combobox("getValue");
				var skfs_select = $("#skfs_select").combobox("getValue");
				var zcry_select = $("#zcry_select").combobox("getValue");
				var url = "${cxt!}/scost/excel?startTime=" + startTime + "&endTime=" + endTime
						+"&organIds="+organIds+"&fyzc_select="+fyzc_select+"&skfs_select="+skfs_select+"&zcry_select="+zcry_select;
				window.location.href = url;
			}
			var organIds=$('#organIds').val();
			var setting = {
				async : {
					enable : true,
					url : '${cxt!}/common/getOrgenTree',
					autoParam : [ "id=ids" ],//, "name=n", "level=lv"
					otherParam : {
						"organIds" : organIds
					},
					type : "post"
				},
				view : {
					dblClickExpand : false
				},
				data : {
					simpleData : {
						enable : true
					}
				},
				callback : {
					onClick : onClick,
					onAsyncSuccess : organTreeOnAsyncSuccess
				}
			};
			var flag=0;//只初始化一次标识
			function organTreeOnAsyncSuccess(event, treeId, msg) {
				if(flag == 0){
					var organTree = $.fn.zTree.getZTreeObj("organSelectTree");
					var nodes = organTree.getNodes();
					flag = 1;
				}
			}
			function onClick(e, treeId, treeNode) {
				var zTree = $.fn.zTree.getZTreeObj("organSelectTree");
				var path = "";
				var sNodes = zTree.getSelectedNodes();
				if (sNodes.length > 0) {
					var node = sNodes[0].getPath();
					for(var i =0;i<node.length;i++){
						if(i == (node.length-1)){
							path += node[i].name;
						}else{
							path += node[i].name + "/";
						}
						
					}
				}
				var cityObj = $("#organ");
				cityObj.attr("value", path);
				$("#organIds").attr("value", treeNode.id);
				hideMenu();
			}
			function showMenu() {
				var cityObj = $("#organ");
				var cityOffset = $("#organ").offset();
				$("#menuContent").css({
					left : cityOffset.left + "px",
					top : cityOffset.top + cityObj.outerHeight() + "px"
				}).slideDown("fast");
				$("body").bind("mousedown", onBodyDown);
			}
			function hideMenu() {
				$("#menuContent").fadeOut("fast");
				$("body").unbind("mousedown", onBodyDown);
			}
			function onBodyDown(event) {
				if (!(event.target.id == "menuBtn"
						|| event.target.id == "menuContent" || $(event.target)
						.parents("#menuContent").length > 0)) {
					hideMenu();
				}
			}
			$.fn.zTree.init($("#organSelectTree"), setting);
		</script>
	</body>
</html>
